1. Technical Field
The present invention relates generally to an improved data processing system and in particular to a method and apparatus for processing errors in a data structure in a data processing system. Still more particularly, the present invention relates generally to a method and apparatus for handling recursive hard links in a directory structure in a data processing system.
2. Description of Related Art
The manipulation of data in a data processing system is well known in the prior art. Data may be manipulated in many ways in a modern state-of-the-art data processing system including: data accessing, data encoding, data communications, data compression, data conversion, data entry, data exchange, data filing, data linking, data locking, data manipulation, data mapping, data modeling, data processing, data recording, data sorting, and data transferring. The large amounts of data that are available to the user of a modern state-of-the-art data processing system often become overwhelming in magnitude and complexity.
In today""s information systems environment, recovery from computer problems whether from hardware or software difficulties, or from administrator error needs to be accomplished quickly and effectively. The first two error classes, hardware and software, are well documented, as computer solutions evolve with both platform advances and the introduction of inadvertent program errors. The later problem type, administrator error, is one which would not be a concern in a perfect world, but which unfortunately occurs all too often. The problem of recursive link creation has stemmed from the actions of inexperienced system administrators as they try to create soft, symbolic links. In particular, the creation of such links, using the UNIX command xe2x80x9cln-sxe2x80x9d is standard fare, and is executed often. The purpose of this command is to create a xe2x80x9csoftxe2x80x9d link pointing to another file or directory, such that the latter entity can be accessed through the symbolic link. A vastly different command, xe2x80x9clinkxe2x80x9d also exists within the UNIX world. This latter command actually redirects the inodes, the file indexing pointers, to physically point at the file or directory in question. The difference between the two commands can be illustrated by comparing the effects of deleting a soft or hard link. If a symbolic link xe2x80x9cdxe2x80x9d is created to another file xe2x80x9caxe2x80x9d, then the link xe2x80x9cdxe2x80x9d is deleted, the file xe2x80x9caxe2x80x9d remains intact. That is to say that only the link is deleted. If a hard link xe2x80x9cdxe2x80x9d is created to another file xe2x80x9caxe2x80x9d, then the link xe2x80x9cdxe2x80x9d is deleted, the file xe2x80x9caxe2x80x9d is also deleted.
Returning back to the fundamental problem, what happens when a recursive hard link, connecting a low-level directory to a higher-level directory, is inadvertently created? The result can be a directory chain like: /usr/a/b/c/d/a/b/c/d/a/b/c/d . . . where xe2x80x9cdxe2x80x9d has a hard link back to directory xe2x80x9caxe2x80x9d. The first inclination in such a case is to try to unlink xe2x80x9caxe2x80x9d from xe2x80x9cdxe2x80x9d. This operation, once the link is created, is not permitted by many UNIX operating system varieties. One solution which has been used in the past is to move one level above xe2x80x9cdxe2x80x9d, the bad link, and unlink form directory xe2x80x9ccxe2x80x9d. This operation is permitted by Advance Interactive Executive (AIX), an operating system from International Business Machines Corporation, although it has unpleasant implications. Any other files and/or directories beneath directory xe2x80x9ccxe2x80x9d would be lost, in addition to the undesired hard link. For example, if the directory structure /a/b/c/d housed a corporate web site, comprising over 10,000 files and the content beneath xe2x80x9ccxe2x80x9d alone totaled 2,000 files, these 2,000 files could not be accessed and would normally be lost. Losing 2,000 files to save the filesystem is an unattractive option. To complicate matters, the nature of a recursive hard link prohibits standard backups from being accomplished. Any backup command, from xe2x80x9cmksysbxe2x80x9d to more selective techniques, will use a xe2x80x9cfindxe2x80x9d command to explore the depths of the directory structure. However, the xe2x80x9cfindxe2x80x9d command will never return from such an infinite structure. Such a situation may crash a data processing system when trying to run backups because the mksysb process may create a rootvg map, a map file, that fills up the entire hard disk, resulting in subsequent system failures. As a result, in such a situation, a back up of some files in the file system cannot be made.
Therefore, it would be advantageous to have an improved method and apparatus for handling recursive links.
The present invention provides a method and apparatus in a data system for processing a recursive link in a directory structure in a data processing system. A path to a directory is identified including the recursive link in the directory structure, wherein the path includes a hierarchy towards a root directory, which is a highest directory. Responsive to identifying the path, a highest unprocessed directory in the path is selected as a current directory and all directories in the directory structure beneath the current directory are identified, excluding a directory below the current directory in the path. This step is performed until all directories in the path down to the directory having the recursive link have been processed to form a set of identified directories. All files within the set of directories are identified to form a set of identified files, which then permits backup operations to proceed.